home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 85 / CD-ROM 85 / CD-ROM 85.iso / aplic / 2sync / 2SyncSetup.exe / newchandlg / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2002-03-20  |  10.9 KB  |  379 lines

  1. function displayInfo(which)
  2. {
  3.    win_info.ch_message.str = dict_win_info_message;
  4.    win_info.ch_name.str = data["ch_name" + which];
  5.    win_install.ch_name.str = data["ch_name" + which];
  6.    if(data["ch_size" + which].length >= 1)
  7.    {
  8.       win_info.ch_size.str = dict_win_info_estimated + data["ch_size" + which] + "Kb";
  9.    }
  10.    win_info.ch_details.str = data["ch_details" + which];
  11.    win_info.ch_name.str = data["ch_name" + which];
  12.    win_info.ch_icon.ph.loadMovie(data["ch_icon" + which]);
  13.    win_install.ch_icon.ph.loadMovie(data["ch_icon" + which]);
  14.    win_result.ch_icon.ph.loadMovie(data["ch_icon" + which]);
  15.    win_info.ch_details.scrollObj.gotoAndPlay("set");
  16.    win_info._visible = true;
  17.    win_install._visible = false;
  18.    win_result._visible = false;
  19. }
  20. function displayInstall()
  21. {
  22.    win_install.percBar.colour = new colour(win_install.percBar);
  23.    win_install.percBar.dark._xScale = 1;
  24.    win_install.message = "2Sync is installing the " + win_info.ch_name.str + " channel:";
  25.    win_install.ch_icon.ph.loadMovie(data["ch_icon" + data.ch_current]);
  26.    win_info._visible = false;
  27.    win_install._visible = true;
  28.    win_result._visible = false;
  29. }
  30. function displayResult()
  31. {
  32.    win_info._visible = false;
  33.    win_install._visible = false;
  34.    win_result._visible = true;
  35. }
  36. function installOK(result)
  37. {
  38.    if(retryOrigPos == null)
  39.    {
  40.       retryOrigPos = win_result.retry._x;
  41.    }
  42.    win_result.next._visible = false;
  43.    if(result == 1)
  44.    {
  45.       win_result.ok._visible = true;
  46.       win_result.fail._visible = false;
  47.       win_result.success = "Successful";
  48.       win_result.message = "Successfully installed the " + win_info.ch_name.str + " channel";
  49.       _level0.data.installed.push(_level0.data.ch_current);
  50.       _level0.data.installed.sort();
  51.       if(_level0.data.installed.length < _level0.data.ch_count)
  52.       {
  53.          win_result.message += "\r\rClick next to see more channels\ror click finish to launch 2Sync.";
  54.          win_result.next._visible = true;
  55.       }
  56.       win_result.retry._visible = false;
  57.       win_result.finish._visible = true;
  58.    }
  59.    else
  60.    {
  61.       win_result.ok._visible = false;
  62.       win_result.fail._visible = true;
  63.       win_result.success = "Failed";
  64.       win_result.message = "The following error occured:\r\r" + win_result.error;
  65.       if(_level0.data.installed.length < _level0.data.ch_count)
  66.       {
  67.          win.result.next._visible = true;
  68.          win_result.retry._x = retryOrigPos;
  69.          win_result.message += "\r\rClick retry to try again, next to see more channels\ror click finish to launch 2Sync.";
  70.       }
  71.       else
  72.       {
  73.          win_result.message += "\r\rClick retry to try again or click finish to launch 2Sync.";
  74.          win_result.retry._x = win.result.next._x;
  75.          win.result.next._visible = false;
  76.       }
  77.       win_result.retry._visible = true;
  78.       win_result.finish._visible = true;
  79.    }
  80.    displayResult();
  81. }
  82. function prevChannel(count)
  83. {
  84.    if(100 < count)
  85.    {
  86.       cancel();
  87.    }
  88.    else
  89.    {
  90.       if(_level0.data.ch_current < 2)
  91.       {
  92.          _level0.data.ch_current = _level0.data.ch_count;
  93.       }
  94.       else
  95.       {
  96.          _level0.data.ch_current--;
  97.       }
  98.       if(_level0.getPos(_level0.data.installed,_level0.data.ch_current) == -1)
  99.       {
  100.          _level0.displayInfo(_level0.data.ch_current);
  101.       }
  102.       else
  103.       {
  104.          _level0.prevChannel(count++);
  105.       }
  106.    }
  107. }
  108. function nextChannel(count)
  109. {
  110.    if(100 < count)
  111.    {
  112.       cancel();
  113.    }
  114.    else
  115.    {
  116.       if(_level0.data.ch_current == _level0.data.ch_count)
  117.       {
  118.          _level0.data.ch_current = 1;
  119.       }
  120.       else
  121.       {
  122.          _level0.data.ch_current = _level0.data.ch_current + 1;
  123.       }
  124.       if(_level0.getPos(_level0.data.installed,_level0.data.ch_current) == -1)
  125.       {
  126.          _level0.displayInfo(_level0.data.ch_current);
  127.       }
  128.       else
  129.       {
  130.          _level0.nextChannel(count++);
  131.       }
  132.    }
  133. }
  134. function finish()
  135. {
  136.    sendFS("ch_new","finish");
  137. }
  138. function install()
  139. {
  140.    sendFS("ch_new","install");
  141.    displayInstall();
  142. }
  143. function remind()
  144. {
  145.    _level0.data.installed.push(_level0.data.ch_current);
  146.    sendFS("ch_new","remind_" + win_info.ch_name.str);
  147.    if(_level0.data.installed.length < _level0.data.ch_count)
  148.    {
  149.       nextChannel();
  150.    }
  151.    else
  152.    {
  153.       sendFS("ch_new","cancel");
  154.    }
  155. }
  156. function forget()
  157. {
  158.    _level0.data.installed.push(_level0.data.ch_current);
  159.    sendFS("ch_new","forget_" + win_info.ch_name.str);
  160.    if(_level0.data.installed.length < _level0.data.ch_count)
  161.    {
  162.       nextChannel();
  163.    }
  164.    else
  165.    {
  166.       sendFS("ch_new","cancel");
  167.    }
  168. }
  169. function cancel()
  170. {
  171.    sendFS("ch_new","cancel");
  172. }
  173. function next()
  174. {
  175.    nextChannel();
  176. }
  177. function retry()
  178. {
  179.    sendFS("ch_new","retry");
  180.    displayInstall();
  181. }
  182. function sendFS(command, args)
  183. {
  184.    fscommand(command,args);
  185. }
  186. function getPos(thisArray, searchItem)
  187. {
  188.    for(item in "thisArray")
  189.    {
  190.       if(searchItem == thisArray[item])
  191.       {
  192.          return item;
  193.       }
  194.    }
  195.    return -1;
  196. }
  197. function setScroll(scrollObj, fieldObj)
  198. {
  199.    scrollObj.totalLines = fieldObj.visibleLines + fieldObj.str.maxScroll + 1;
  200.    scrollObj.scrollBar._yScale = int(fieldObj.visibleLines / scrollObj.totalLines * 100);
  201.    scrollObj.scrollBar._y = 0;
  202.    scrollObj.travel = scrollObj.constraint._height - scrollObj.scrollBar._height;
  203.    fieldObj.str.scroll = 1;
  204.    scrollObj._visible = true;
  205. }
  206. function setChannelColour()
  207. {
  208.    if(_level0.env != null && _level0.env.ch != null)
  209.    {
  210.       var tempObjRef = _level0.env.ch;
  211.       var states = ["normal","over","pressed"];
  212.       var colObjects = ["dark","light","text"];
  213.       var setTrans = ["ra","rb","ga","gb","ba","bb","aa","ab"];
  214.       tempObjRef.none = new Object();
  215.       tempObjRef.none.dark = {ra:100,rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0};
  216.       tempObjRef.none.light = {ra:100,rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0};
  217.       tempObjRef.none.text = {ra:100,rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0};
  218.       tempObjRef.clear = new Object();
  219.       tempObjRef.clear.dark = {ra:0,rb:0,ga:0,gb:0,ba:0,bb:0,aa:0,ab:0};
  220.       tempObjRef.clear.light = {ra:0,rb:0,ga:0,gb:0,ba:0,bb:0,aa:0,ab:0};
  221.       tempObjRef.clear.text = {ra:0,rb:0,ga:0,gb:0,ba:0,bb:0,aa:0,ab:0};
  222.       i = 0;
  223.       while(i < states.length)
  224.       {
  225.          tempObjRef[states[i]] = new Object();
  226.          var stateObj = tempObjRef[states[i]];
  227.          c = 0;
  228.          while(c < colObjects.length)
  229.          {
  230.             stateChar1 = states[i].charAt(0);
  231.             stateObj[colObjects[c]] = new Object();
  232.             t = 0;
  233.             while(t < setTrans.length)
  234.             {
  235.                stateObj[colObjects[c]][setTrans[t]] = tempObjRef.colour[stateChar1 + "_" + colObjects[c] + "_" + setTrans[t]];
  236.                t++;
  237.             }
  238.             c++;
  239.          }
  240.          i++;
  241.       }
  242.       if(_level0.colourObjStack == null)
  243.       {
  244.          _level0.colourObjStack = [];
  245.       }
  246.       else
  247.       {
  248.          for(i in "_level0:colourObjStack")
  249.          {
  250.             if(colourObjStack[i] == null or colourObjStack[i].colour == null)
  251.             {
  252.                colourObjStack.splice(i,1);
  253.             }
  254.             else
  255.             {
  256.                colourObjStack[i].colour.refresh();
  257.             }
  258.          }
  259.       }
  260.    }
  261. }
  262. function colour(me)
  263. {
  264.    this.state = new Object();
  265.    this.state.clear = _level0.env.ch.clear;
  266.    this.state.none = _level0.env.ch.none;
  267.    this.state.normal = _level0.env.ch.normal;
  268.    this.state.over = _level0.env.ch.over;
  269.    this.state.pressed = _level0.env.ch.pressed;
  270.    this.dInst = new Color(me.dark);
  271.    this.lInst = new Color(me.light);
  272.    this.tInst = new Color(me.text);
  273.    this.setState = colourObj_setState;
  274.    this.none = function()
  275.    {
  276.       this.setState("none");
  277.    };
  278.    this.normal = function()
  279.    {
  280.       this.setState("normal");
  281.    };
  282.    this.rollover = function()
  283.    {
  284.       this.setState("over");
  285.    };
  286.    this.pressed = function()
  287.    {
  288.       this.setState("pressed");
  289.    };
  290.    this.clear = function()
  291.    {
  292.       this.setState("clear");
  293.    };
  294.    this.init = colourObj_init;
  295.    this.refresh = colourObj_refresh;
  296.    this.init();
  297.    _level0.colourObjStack.push(me);
  298. }
  299. function colourObj_setState(which)
  300. {
  301.    this.dInst.setTransform(this.state[which].dark);
  302.    this.lInst.setTransform(this.state[which].light);
  303.    this.tInst.setTransform(this.state[which].text);
  304.    this.currentState = which;
  305. }
  306. function colourObj_init()
  307. {
  308.    this.normal();
  309. }
  310. function colourObj_refresh()
  311. {
  312.    this.state.normal = _level0.env.ch.normal;
  313.    this.state.over = _level0.env.ch.over;
  314.    this.state.pressed = _level0.env.ch.pressed;
  315.    this.state.clear = _level0.env.ch.clear;
  316.    this.setState(this.currentState);
  317. }
  318. function initDlg()
  319. {
  320.    _level0.data.installed = new Array();
  321.    setChannelColour();
  322.    win_title.colour = new colour(_level0.win_title);
  323.    win_frame.colour = new colour(_level0.win_frame);
  324.    win_bottom.colour = new colour(_level0.win_bottom);
  325.    win_result.ok.colour = new colour(win_result.ok);
  326.    win_result.fail.colour = new colour(win_result.fail);
  327.    win_frame.dark._alpha = 45;
  328.    if(1 < _level0.data.ch_count)
  329.    {
  330.       win_info.ch_prev.colour = new colour(win_info.ch_prev);
  331.       win_info.ch_prev.colour.none();
  332.       win_info.ch_next.colour = new colour(win_info.ch_next);
  333.       win_info.ch_next.colour.none();
  334.       win_info.backFrame.colour = new colour(win_info.backFrame);
  335.       win_install.backFrame.colour = new colour(win_install.backFrame);
  336.       win_result.backFrame.colour = new colour(win_result.backFrame);
  337.       win_info.ch_prev.release = prevChannel;
  338.       win_info.ch_next.release = nextChannel;
  339.    }
  340.    else
  341.    {
  342.       win_info.ch_prev._visible = false;
  343.       win_info.ch_next._visible = false;
  344.    }
  345.    win_info.ch_details.scrollObj.prev.press = function()
  346.    {
  347.       _level0.scrollRoutine.scrollObj = this._parent;
  348.       _level0.scrollRoutine.fieldObj = this._parent._parent;
  349.       _level0.scrollRoutine.dir = -1;
  350.       _level0.scrollRoutine.gotoAndPlay("scroll");
  351.    };
  352.    win_info.ch_details.scrollObj.prev.release = function()
  353.    {
  354.       _level0.scrollRoutine.gotoAndStop("stop");
  355.    };
  356.    win_info.ch_details.scrollObj.next.press = function()
  357.    {
  358.       _level0.scrollRoutine.scrollObj = this._parent;
  359.       _level0.scrollRoutine.fieldObj = this._parent._parent;
  360.       _level0.scrollRoutine.dir = 1;
  361.       _level0.scrollRoutine.gotoAndPlay("scroll");
  362.    };
  363.    win_info.ch_details.scrollObj.next.release = function()
  364.    {
  365.       _level0.scrollRoutine.gotoAndStop("stop");
  366.    };
  367.    win_title.text.str = dict_win_info_title;
  368.    win_info.ch_details.scrollObj.gotoAndPlay("set");
  369.    displayInfo(data.ch_current);
  370. }
  371. fscommand("allowScale",0);
  372. stop();
  373. win_info._visible = false;
  374. win_install._visible = false;
  375. win_result._visible = false;
  376. dict_win_info_title = "2Sync: New channel available";
  377. dict_win_info_estimated = "Download size: ";
  378. fscommand("ch_new","init");
  379.